package com.lingshi.shopping_manager_api.config;

import cn.dev33.satoken.interceptor.SaInterceptor;
import com.lingshi.shopping_manager_api.security.CheckLoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册拦截器（登录拦截器）
        registry.addInterceptor(new CheckLoginInterceptor())
                .addPathPatterns("/**")//拦截所有资源（请求）
                .excludePathPatterns("/admin/login");//放行的资源（请求）

        //注册授权拦截器-(sa-token) 打开鉴权功能
        registry.addInterceptor(new SaInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/ws");
    }

}
